<template>

  <div class="book-header">
      <el-form :inline="true" :model="formInline" class="demo-form-inline">
      <el-form-item label="图书名称" >
        <el-input v-model="formInline.user" placeholder="请输入书名" clearable />
      </el-form-item>
      <el-form-item label="图书类别">
        <el-select style="width: 200px;"
          v-model="formInline.region"
          placeholder="请选择"
          clearable
        >
          <el-option label="小说" value="1" />
          <el-option label="散文" value="2" />
        </el-select>
      </el-form-item>
      <el-form-item label="出版时间">
        <el-date-picker
          v-model="formInline.date"
          type="datetimerange"
          placeholder="选择日期"
          clearable
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">搜索</el-button>
        <el-button type="primary" @click="onSubmit">添加</el-button>
      </el-form-item>
    </el-form>
  </div>
  
  <div class="book-content">
      <el-table :data="tableData" style="width: 100%">
      <el-table-column type="index" label="序号" width="80" />
      <el-table-column prop="date" label="图书名称" width="150" />
      <el-table-column prop="name" label="图书价格" width="120" />
      <el-table-column prop="state" label="作者" width="120" />
      <el-table-column prop="city" label="ISBN" width="120" />
      <el-table-column prop="address" label="出版时间" width="300" />
      <el-table-column prop="zip" label="库存" width="120" />
  
      <el-table-column prop="isDeleted" label="是否可用" width="120">
  
          <!-- 卡槽 -->
          <template #default="scoped">
              <!-- 如果 是1  -->
              <el-tag class="ml-2" type="success" v-if="scoped.row.isDeleted === 1">可用</el-tag>
              <el-tag class="ml-2" type="danger" v-if="scoped.row.isDeleted === 0">不可用</el-tag>
          
          </template>
  
              
  
  
      </el-table-column>
  
  
      <el-table-column fixed="right" label="操作" width="120">
        <template #default>
          <el-button link type="primary" size="small" @click="handleClick"
            >编辑</el-button
          >
          <el-button link type="danger" size="small">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
  
  </div>
  
  <div class="book-footer" style="margin-top: 20px;">
    <el-pagination background layout="prev, pager, next" 
    :total="500" small/>
  </div>
  
  
  
  
  </template>
  
  <script setup>
  import { reactive } from 'vue'
  
  const formInline = reactive({
    user: '',
    region: '',
    date: '',
  })
  
  const onSubmit = () => {
    console.log('submit!')
  }
  
  
  
  
  const handleClick = () => {
    console.log('click')
  }
  
  const tableData = [
    {
      date: '2016-05-03',
      name: 'Tom',
      state: 'California',
      city: 'Los Angeles',
      address: 'No. 189, Grove St, Los Angeles',
      zip: 'CA 90036',
      isDeleted: 1,
    },
    {
      date1: '2016-05-02',
      name: 'Tom',
      state: 'California',
      city: 'Los Angeles',
      address: 'No. 189, Grove St, Los Angeles',
      zip: 'CA 90036',
      isDeleted: 1,
    },
    {
      date: '2016-05-04',
      name: 'Tom',
      state: 'California',
      city: 'Los Angeles',
      address: 'No. 189, Grove St, Los Angeles',
      zip: 'CA 90036',
      isDeleted: 0,
    },
    {
      date: '2016-05-01',
      name: 'Tom',
      state: 'California',
      city: 'Los Angeles',
      address: 'No. 189, Grove St, Los Angeles',
      zip: 'CA 90036',
      isDeleted: 1,
    },
  ]
  </script>
  
  <style scoped>
  
  </style>